<?php
/*
	我的足迹
*/
defined('BY_JYA') or exit('error');
$this->model('member')->checklogin();
$return['ice_menu_array']=array( array('menu_key' => 'index', 'menu_name' => '我的足迹', 'menu_url' => custom_url('jy_weishop/member.history/',true)) );
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
if($_RQ['op']=='main'){
	$return['list']=array();
	set_html('title','我的足迹');
	exi($return);
}
// js 获取数据
if($_RQ['op']=='getlist'){
	$params=array(
		'uniacid'=>$_SESSION['uniacid'],
		'mid'=>$_SESSION['uid'],
	);
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$return['list']=pdo_getslice('jy_weishop_member_history',$params,array($pindex,$psize),$total,array(),'','createtime desc');
	foreach($return['list'] as $k=>&$item){
		$goods=pdo_get('jy_weishop_goods',array('id'=>$item['goodsid']),array('title','image','marketprice','price'));
		if($goods){
			$item=array_merge($goods,$item);
			$item['createtime']=date('Y/m/d H:i:s',$item['createtime']);	
		}else{
			//unset($return['list'][$k]);
			pdo_delete('jy_weishop_member_history',array('id'=>$item['id'],'uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['mid']));
		}
		
	}
	exi($return);
}	
if($_RQ['op']=='del'){	
	$dels=str_array($_RQ['del']);
	if(!$dels){
		exi('请先选择要删除的项目！','error');
	}
	foreach($dels as $id){
		$id=intval($id);
		if($id){
			pdo_delete('jy_weishop_member_history',array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));
		}
	}
	exi('删除成功！','','main');
}	